/**违禁词管理 */
<template>
  <div class="word-page">

    <div class="word-bottom-box">
      <el-card shadow="always">
        <div slot="header">
          <line-header title="违禁词管理"></line-header>
        </div>
        <div class="card-body">

          <div class="table-bottom-box">
            <el-button type="primary" @click="hkClickLook">+ 新增违禁词</el-button>
          </div>
          <div class="table-box">
            <el-table
              :data="tableList"
              style="width: 100%"
              header-cell-class-name="header-cell-class-name"
              stripe
              border
            >
              <el-table-column prop="coding" label="编号" align="center">
              </el-table-column>
              <el-table-column prop="name" label="违禁词库名称" align="center">
              </el-table-column>
              <el-table-column
                prop="createTime"
                label="创建时间"
                align="center"
              >
                <template slot-scope="{ row }">
                  <div>{{hkGetTimeFmt(row.createTime)}}</div>
                </template>
              </el-table-column>
              <el-table-column
                prop="createTime"
                label="创建时间"
                align="center"
              >
                <template slot-scope="{ row }">
                  <div>{{hkGetTimeFmt(row.updateTime)}}</div>
                </template>
              </el-table-column>

              ><el-table-column label="操作" align="center">
              <template slot-scope="{ row }">
                <el-button
                  type="primary"
                  size="small"
                  icon="el-icon-view"
                  plain
                  @click="hkClickLook(row)"
                >编辑</el-button>
                <el-button
                  type="primary"
                  size="small"
                  icon="el-icon-view"
                  plain
                  @click="hkRemoveWord(row)"
                >删除</el-button>

              </template>
            </el-table-column>
            </el-table>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
  import LineHeader from "@/components/line-header/index";
  import { invoiceStatusList, invoiceClass } from "@/utils/tools";
  import {trace} from "../../utils/trace"
  import {mapGetters} from "vuex"
  import {hkGetTimeFmt, hkShowSuccessText} from "../../utils/tools"

  export default {
    components: { LineHeader },
    props: {},
    data() {
      return {
        hkGetTimeFmt: hkGetTimeFmt,

        tableList: [
        ],
        invoiceClass: invoiceClass,
        statusList: invoiceStatusList
      };
    },
    filters: {

    },
    watch: {},
    computed: {
      ...mapGetters(["userInfo"])
    },
    methods: {
      //编辑
      hkClickLook(item) {
        let path = "/word/add";

        if(item){
          this.$router.push({
            path: path,
            query: { id: item.id }
          });
        }else{
          this.$router.push({
            path: path,
          });
        }
      },
      //删除
      async hkRemoveWord(item) {
        let {id} = item;
        let res = await this.$store.dispatch("promote/wordsDel",{id});
        if(res.code==2000){
          hkShowSuccessText("违禁词删除成功！");

          this.getList();
        }
      },
      getList(){
        this.$store.dispatch('promote/wordsQuery').then((data) => {
          trace("wordsQuery-获取违禁词的列表-data", data);
          this.tableList = data.data;
        })
          .catch((err) => {
            trace("获取发票的列表-wordsQuery-err", err)
          })
      },
    },
    created() {
      this.getList();
    },
    mounted() {}
  };
</script>
<style lang="scss" scoped>
  .word-top-box {
    .card-body {
      .top-title-box {
        margin-right: 10px;
      }
    }
  }
  ::v-deep .header-cell-class-name {
    background: #ecf0f3;
  }
  .word-bottom-box {
    margin-top: 30px;
    .table-top-box {
      display: flex;
      align-items: center;
      justify-content: space-between;
      .top-left-box {
        .el-select {
          width: 120px;
          margin: 0 5px;
        }
        .el-input {
          width: 180px;
          margin: 0 5px;
        }
      }
    }
    .table-bottom-box {
      margin: 20px 5px;
    }
  }
</style>
